package com.dongpu.springboot.rabbitmq.config;

import com.dongpu.springboot.rabbitmq.pojo.Address;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author biyuyang
 *
 * 集中负责给指定队列发送消息
 */
@Component
public class MQSender {

	@Autowired
	private RabbitTemplate rabbitTemplate;

	@Value("${rabbit.address.updatequeuename}")
	private String addressUpdateQueue;

	@Value("${rabbit.address.insertqueuename}")
	private String addressInsertQueue;

	@Value("${rabbit.address.deletequeuename}")
	private String addressDeleteQueue;

	public void update(Address bo){
		System.out.println("MQSender update ....."+ bo.toString());
		rabbitTemplate.convertAndSend(addressUpdateQueue,bo);
	}
	public void insert(Address bo){
		System.out.println("MQSender insert ....."+ bo.toString());
		rabbitTemplate.convertAndSend(addressInsertQueue,bo);
	}

	public void delete(Address bo){
		System.out.println("MQSender delete ....."+ bo.toString());
		rabbitTemplate.convertAndSend(addressDeleteQueue,bo);
	}

}
